function createStandardCompatibilityNotification(message) {
  var outerDiv = getOuterCompatibilityDiv();
  var messageDiv = getMessageDiv(message);
  var closeDiv = getCloseDiv();

  outerDiv.appendChild(messageDiv);
  outerDiv.appendChild(closeDiv);

  document.getElementsByTagName('body')[0].appendChild(outerDiv);
}

function getOuterCompatibilityDiv() {
  var outerDiv = document.createElement("div");
  outerDiv.setAttribute('id', 'bristleCompatibilityDiv');
  outerDiv.setAttribute('style', 'font-size: 10pt; position: absolute; top: 0; left: 0; width:100%; border: solid 1px #dcdcdc;  background: #dcdcdc');
  return outerDiv;
}

function getMessageDiv(message) {
  var messageDiv = document.createElement("div");
  messageDiv.setAttribute('style', 'float:left; display:inline;  line-height:30px; vertical-align:middle; height:25px;');
  messageDiv.innerHTML = message;
  return messageDiv;
}

function getCloseDiv() {
  var closeDiv = document.createElement("div");
  closeDiv.setAttribute('style', 'float:right;margin-right: 5px; line-height:30px; vertical-align:middle;');
  closeDiv.innerHTML = "<a href='#' style='color: #466b16; text-decoration: none;' onclick='Bristle.compatibility.closeCompatibilityNotification()'>close</a>";
  return closeDiv;
}

Bristle.compatibility = {};

Bristle.compatibility.getFlashBridgeUsedNotification = function() {
  createStandardCompatibilityNotification('Your browser does not support Html 5 Websockets, FlashBridge is used instead.');
};

Bristle.compatibility.getNoCompatibilityNotification = function() {
  createStandardCompatibilityNotification('Your browser does not support Html 5 Websockets, neither it has enabled Flash 10.0+ plugin.');
};

Bristle.compatibility.getFullCompatibilityNotification = function() {
};

Bristle.compatibility.showCompatibilityInfo = true;
Bristle.compatibility.compatibilityInfoSeen = false;

Bristle.compatibility.getCompatibilityInfo = function() {
  if (Bristle.compatibility.showCompatibilityInfo && !Bristle.compatibility.compatibilityInfoSeen) {
    Bristle.compatibility.compatibilityInfoSeen = true;
    if (WebSocket == null) {
      Bristle.compatibility.getNoCompatibilityNotification();
    } else if (jws.JWS_FLASHBRIDGE != null) {
      Bristle.compatibility.getFlashBridgeUsedNotification();
    } else {
      Bristle.compatibility.getFullCompatibilityNotification();
    }
  }
};

Bristle.compatibility.closeCompatibilityNotification = function() {
  var outerDiv = document.getElementById("bristleCompatibilityDiv");
  outerDiv.parentNode.removeChild(outerDiv);
};
